<?php


function make_link($controller, $content, $method = null, $data = null){
	if(!is_null($method)) {
		$methodRewrite = '/'.strtolower($params['method']).'/' ;
		$methodNormal	= '&m='.strtolower($params['method']) ;
		if(!is_null($data)) {
			$dataRewrite 	= $params['data'].'/' ;
			$dataNormal 	= '&data='.$params['data'] ;
		}
	} else {
		$methodRewrite = '/' ;
		$methodNormal	= '' ;
	}
	
	// check if controller exists
	if(file_exists(SITE_PATH.$controller.EXT)) {
		if(true === REWRITE_ENGINE) 
			return '<a href="'.BASE_URL.$controller.$methodRewrite.$dataRewrite.'">'.$content.'</a>';
		else
			return '<a href="'.BASE_URL.'index.php?c='.$controller.$methodNormal.$dataNormal.'">'.$content.'</a>';
	}
	return '';
}

?>